Public Class OrderItems
    Inherits DABase

    Public Sub SelectByOrderID(ByVal orderID As Object, ByRef ds As DataSet, ByVal tableName As String)
        Dim sqlCommand As New SqlClient.SqlCommand

        sqlCommand.CommandText = "[GetOrderItemsByOrderID]"
        sqlCommand.CommandType = System.Data.CommandType.StoredProcedure
        sqlCommand.Connection = Me.Connection
        sqlCommand.Transaction = Me.Transaction

        Dim param As SqlParameter
        param = New SqlClient.SqlParameter("@ORDER_ID_FK", System.Data.SqlDbType.Int, 4, "ORDER_ID_FK")
        param.Value = orderID
        sqlCommand.Parameters.Add(param)

        Dim da As New SqlDataAdapter(sqlCommand)

        da.Fill(ds, tableName)

    End Sub

    Protected Overrides Function getDeleteCommand() As System.Data.SqlClient.SqlCommand
        Dim sqlCommand As New SqlClient.SqlCommand

        sqlCommand.CommandText = "[OrderItemDeleteCommand]"
        sqlCommand.CommandType = System.Data.CommandType.StoredProcedure
        sqlCommand.Connection = Me.Connection
        sqlCommand.Transaction = Me.Transaction

        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@RETURN_VALUE", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue, False, CType(0, Byte), CType(0, Byte), "", System.Data.DataRowVersion.Current, Nothing))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_OI_ID_PK", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "OI_ID_PK", System.Data.DataRowVersion.Original, Nothing))
        'sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_ADJUSTED_APRROVED_BY_ID_FK", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "ADJUSTED_APRROVED_BY_ID_FK", System.Data.DataRowVersion.Original, Nothing))
        'sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_ADJUSTED_BY_ID_FK", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "ADJUSTED_BY_ID_FK", System.Data.DataRowVersion.Original, Nothing))
        'sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_ADJUSTED_DATE", System.Data.SqlDbType.DateTime, 8, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "ADJUSTED_DATE", System.Data.DataRowVersion.Original, Nothing))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_ADJUSTED_QUANTITY", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "ADJUSTED_QUANTITY", System.Data.DataRowVersion.Original, Nothing))
        'sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_APPROVAL_DATE", System.Data.SqlDbType.DateTime, 8, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "APPROVAL_DATE", System.Data.DataRowVersion.Original, Nothing))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_COLOR_ID_FK", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "COLOR_ID_FK", System.Data.DataRowVersion.Original, Nothing))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_IS_FIXED", System.Data.SqlDbType.Bit, 1, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "IS_FIXED", System.Data.DataRowVersion.Original, Nothing))
        'sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_MIMS_PRODUCT_CODE_ID_FK", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "MIMS_PRODUCT_CODE_ID_FK", System.Data.DataRowVersion.Original, Nothing))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_ORDER_ID_FK", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "ORDER_ID_FK", System.Data.DataRowVersion.Original, Nothing))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_PACKING", System.Data.SqlDbType.TinyInt, 1, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "PACKING", System.Data.DataRowVersion.Original, Nothing))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_PRODUCT_CODE_ID_FK", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "PRODUCT_CODE_ID_FK", System.Data.DataRowVersion.Original, Nothing))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_QUANTITY", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "QUANTITY", System.Data.DataRowVersion.Original, Nothing))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_SPECIAL_INSTRUCTIONS", System.Data.SqlDbType.VarChar, 2000, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "SPECIAL_INSTRUCTIONS", System.Data.DataRowVersion.Original, Nothing))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_USE_FROM_BO_ITEM", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "USE_FROM_BO_ITEM", System.Data.DataRowVersion.Original, Nothing))

        Return sqlCommand
    End Function

    Protected Overrides Function getInsertCommand() As System.Data.SqlClient.SqlCommand
        Dim sqlCommand As New SqlClient.SqlCommand

        sqlCommand.CommandText = "[OrderItemInsertCommand]"
        sqlCommand.CommandType = System.Data.CommandType.StoredProcedure
        sqlCommand.Connection = Me.Connection
        sqlCommand.Transaction = Me.Transaction

        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@RETURN_VALUE", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue, False, CType(0, Byte), CType(0, Byte), "", System.Data.DataRowVersion.Current, Nothing))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@ORDER_ID_FK", System.Data.SqlDbType.Int, 4, "ORDER_ID_FK"))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@PRODUCT_CODE_ID_FK", System.Data.SqlDbType.Int, 4, "PRODUCT_CODE_ID_FK"))
        'sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@MIMS_PRODUCT_CODE_ID_FK", System.Data.SqlDbType.Int, 4, "MIMS_PRODUCT_CODE_ID_FK"))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@COLOR_ID_FK", System.Data.SqlDbType.Int, 4, "COLOR_ID_FK"))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@PACKING", System.Data.SqlDbType.TinyInt, 1, "PACKING"))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@QUANTITY", System.Data.SqlDbType.Int, 4, "QUANTITY"))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@IS_FIXED", System.Data.SqlDbType.Bit, 1, "IS_FIXED"))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@SPECIAL_INSTRUCTIONS", System.Data.SqlDbType.VarChar, 2000, "SPECIAL_INSTRUCTIONS"))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@USE_FROM_BO_ITEM", System.Data.SqlDbType.Int, 4, "USE_FROM_BO_ITEM"))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@ADJUSTED_QUANTITY", System.Data.SqlDbType.Int, 4, "ADJUSTED_QUANTITY"))
        'sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@ADJUSTED_BY_ID_FK", System.Data.SqlDbType.Int, 4, "ADJUSTED_BY_ID_FK"))
        'sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@ADJUSTED_DATE", System.Data.SqlDbType.DateTime, 8, "ADJUSTED_DATE"))
        'sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@ADJUSTED_APRROVED_BY_ID_FK", System.Data.SqlDbType.Int, 4, "ADJUSTED_APRROVED_BY_ID_FK"))
        'sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@APPROVAL_DATE", System.Data.SqlDbType.DateTime, 8, "APPROVAL_DATE"))

        Return sqlCommand
    End Function

    Protected Overrides Function getSelectCommand(ByVal keys() As Object) As System.Data.SqlClient.SqlCommand
        Dim sqlCommand As New SqlClient.SqlCommand

        sqlCommand.CommandText = "[OrderItemSelectCommand]"
        sqlCommand.CommandType = System.Data.CommandType.StoredProcedure
        sqlCommand.Connection = Me.Connection
        sqlCommand.Transaction = Me.Transaction

        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@RETURN_VALUE", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue, False, CType(0, Byte), CType(0, Byte), "", System.Data.DataRowVersion.Current, Nothing))
        Dim param As SqlParameter
        param = New SqlClient.SqlParameter("@OI_ID_PK", System.Data.SqlDbType.Int, 4, "OI_ID_PK")
        param.Value = keys(0)
        sqlCommand.Parameters.Add(param)

        Return sqlCommand
    End Function

    Protected Overrides Function getUpdateCommand() As System.Data.SqlClient.SqlCommand
        Dim sqlCommand As New SqlClient.SqlCommand

        sqlCommand.CommandText = "[OrderItemUpdateCommand]"
        sqlCommand.CommandType = System.Data.CommandType.StoredProcedure
        sqlCommand.Connection = Me.Connection
        sqlCommand.Transaction = Me.Transaction

        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@RETURN_VALUE", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue, False, CType(0, Byte), CType(0, Byte), "", System.Data.DataRowVersion.Current, Nothing))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@ORDER_ID_FK", System.Data.SqlDbType.Int, 4, "ORDER_ID_FK"))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@PRODUCT_CODE_ID_FK", System.Data.SqlDbType.Int, 4, "PRODUCT_CODE_ID_FK"))
        'sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@MIMS_PRODUCT_CODE_ID_FK", System.Data.SqlDbType.Int, 4, "MIMS_PRODUCT_CODE_ID_FK"))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@COLOR_ID_FK", System.Data.SqlDbType.Int, 4, "COLOR_ID_FK"))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@PACKING", System.Data.SqlDbType.TinyInt, 1, "PACKING"))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@QUANTITY", System.Data.SqlDbType.Int, 4, "QUANTITY"))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@IS_FIXED", System.Data.SqlDbType.Bit, 1, "IS_FIXED"))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@SPECIAL_INSTRUCTIONS", System.Data.SqlDbType.VarChar, 2000, "SPECIAL_INSTRUCTIONS"))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@USE_FROM_BO_ITEM", System.Data.SqlDbType.Int, 4, "USE_FROM_BO_ITEM"))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@ADJUSTED_QUANTITY", System.Data.SqlDbType.Int, 4, "ADJUSTED_QUANTITY"))
        'sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@ADJUSTED_BY_ID_FK", System.Data.SqlDbType.Int, 4, "ADJUSTED_BY_ID_FK"))
        'sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@ADJUSTED_DATE", System.Data.SqlDbType.DateTime, 8, "ADJUSTED_DATE"))
        'sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@ADJUSTED_APRROVED_BY_ID_FK", System.Data.SqlDbType.Int, 4, "ADJUSTED_APRROVED_BY_ID_FK"))
        'sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@APPROVAL_DATE", System.Data.SqlDbType.DateTime, 8, "APPROVAL_DATE"))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_OI_ID_PK", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "OI_ID_PK", System.Data.DataRowVersion.Original, Nothing))
        'sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_ADJUSTED_APRROVED_BY_ID_FK", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "ADJUSTED_APRROVED_BY_ID_FK", System.Data.DataRowVersion.Original, Nothing))
        'sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_ADJUSTED_BY_ID_FK", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "ADJUSTED_BY_ID_FK", System.Data.DataRowVersion.Original, Nothing))
        'sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_ADJUSTED_DATE", System.Data.SqlDbType.DateTime, 8, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "ADJUSTED_DATE", System.Data.DataRowVersion.Original, Nothing))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_ADJUSTED_QUANTITY", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "ADJUSTED_QUANTITY", System.Data.DataRowVersion.Original, Nothing))
        'sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_APPROVAL_DATE", System.Data.SqlDbType.DateTime, 8, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "APPROVAL_DATE", System.Data.DataRowVersion.Original, Nothing))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_COLOR_ID_FK", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "COLOR_ID_FK", System.Data.DataRowVersion.Original, Nothing))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_IS_FIXED", System.Data.SqlDbType.Bit, 1, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "IS_FIXED", System.Data.DataRowVersion.Original, Nothing))
        'sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_MIMS_PRODUCT_CODE_ID_FK", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "MIMS_PRODUCT_CODE_ID_FK", System.Data.DataRowVersion.Original, Nothing))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_ORDER_ID_FK", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "ORDER_ID_FK", System.Data.DataRowVersion.Original, Nothing))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_PACKING", System.Data.SqlDbType.TinyInt, 1, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "PACKING", System.Data.DataRowVersion.Original, Nothing))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_PRODUCT_CODE_ID_FK", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "PRODUCT_CODE_ID_FK", System.Data.DataRowVersion.Original, Nothing))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_QUANTITY", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "QUANTITY", System.Data.DataRowVersion.Original, Nothing))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_SPECIAL_INSTRUCTIONS", System.Data.SqlDbType.VarChar, 2000, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "SPECIAL_INSTRUCTIONS", System.Data.DataRowVersion.Original, Nothing))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_USE_FROM_BO_ITEM", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "USE_FROM_BO_ITEM", System.Data.DataRowVersion.Original, Nothing))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@OI_ID_PK", System.Data.SqlDbType.Int, 4, "OI_ID_PK"))

        Return sqlCommand
    End Function
End Class
